﻿using FireStarterModeller.BO;
using Habanero.BO.ClassDefinition;
using Habanero.Testability;

namespace FireStarterModeller.Test.BO
{
    public class TestUtilsUIColumnLayout
    {

        public static BOTestFactory<UIColumnLayout> GetFactory()
        {
            return BOTestFactoryRegistry.Instance.Resolve<UIColumnLayout>();
        }


        /// <summary>
        /// Creates a new saved UIColumnLayout with a random value assigned to every property
        /// </summary>
        public static UIColumnLayout CreateSavedUIColumnLayout()
        {
            UIColumnLayout uIColumnLayout = CreateUnsavedValidUIColumnLayout();
            uIColumnLayout.Save();
            return uIColumnLayout;
        }

        /// <summary>
        /// Creates a new unsaved UIColumnLayout with a random value assigned to every property
        /// </summary>
        public static UIColumnLayout CreateUnsavedValidUIColumnLayout()
        {
/*            UIColumnLayout uIColumnLayout = new UIColumnLayout();
            uIColumnLayout.Width = TestUtilsShared.GetRandomInt();
            uIColumnLayout.Generated = TestUtilsShared.GetRandomBoolean();
            uIColumnLayout.UITabID = TestUtilsUITab.CreateSavedUITab().UITabID;*/
            return GetFactory().CreateValidBusinessObject();
        }
	    
        /// <summary>
        /// Creates a new unsaved UIColumnLayout where all properties are null, except ID properties
        /// and those with default values.  If there are compulsory properties without
        /// defaults, saving the object will throw an exception.
        /// </summary>
        public static UIColumnLayout CreateUnsavedDefaultUIColumnLayout()
        {
            UIColumnLayout uIColumnLayout = new UIColumnLayout();
            return uIColumnLayout;
        }
    }

// ReSharper disable UnusedMember.Global
    public class UIColumnLayoutTestFactory : BOTestFactory<UIColumnLayout>
    {
        public UIColumnLayoutTestFactory()
        {
            RegisterValueGeneratorForOrdinalPos();
        }

        public UIColumnLayoutTestFactory(UIColumnLayout bo)
            : base(bo)
        {
            RegisterValueGeneratorForOrdinalPos();
        }

        private void RegisterValueGeneratorForOrdinalPos()
        {
            var classDef = ClassDef.Get<UIColumnLayout>();
            var propDef = classDef.GetPropDef("OrdinalPosition");
            _validValueGenRegistry.Register(propDef, typeof(ValidValueGeneratorIncrementalInt));
        }
    }
    // ReSharper restore UnusedMember.Global
}